﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace HuiLian.Cloud.Controls
{
    public class BorderButton : Button
    {
        /// <summary>
        /// 注册边框颜色
        /// </summary>
        public static readonly DependencyProperty BorderColorProperty = DependencyProperty.Register("BorderColor", 
            typeof(Brush), typeof(BorderButton), new PropertyMetadata(Brushes.LightGray, OnPropertyChanged));

        /// <summary>
        /// 按钮字体颜色
        /// </summary>
        [Description("边框颜色"), Category("边框按钮")]
        public Brush BorderColor
        {
            set { SetValue(BorderColorProperty, value); }
            get { return (Brush)GetValue(BorderColorProperty); }
        }

        /// <summary>
        /// 注册边框
        /// </summary>
        public static readonly DependencyProperty ButtonThicknessProperty = DependencyProperty.Register("ButtonThickness", 
            typeof(Thickness), typeof(BorderButton), new PropertyMetadata(new Thickness() { Bottom = 1, Left = 1, Right = 1, Top = 1 }, OnPropertyChanged));

        public Thickness ButtonThickness
        {
            set { SetValue(ButtonThicknessProperty, value); }
            get { return (Thickness)GetValue(ButtonThicknessProperty); }
        }

        private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            BorderButton button = d as BorderButton;
            if (e.Property.Name.Equals("BorderColor"))
                button.BorderColor = (Brush)e.NewValue;
            if (e.Property.Name.Equals("ButtonThickness"))
                button.ButtonThickness = (Thickness)e.NewValue;
        }
    }
}
